<?php
	include("../connect.php");
	
	$ms_mt = $_REQUEST['ms'];
	
	mysql_query("SET character_set_results=utf8"); //lấy dữ liệu tiếng việt từ csdl
	$sql="SELECT *,  DATE_FORMAT(ngay_dang,'%d-%m-%Y') AS ngay
		  FROM mau_tin_rv a, the_loai_tin b, muc_tin c
		  WHERE a.ms_muc_tin = c.ms_muc_tin
		  		AND b.ms_loai_tin = c.ms_loai_tin
				AND DATE_ADD(a.ngay_dang, INTERVAL a.thoi_gian_song DAY) <= NOW()
		  ORDER BY a.ngay_dang DESC";
	$rs=mysql_query($sql);
?>
<tr>
    <td colspan="12"><h2><b>Danh sách mẩu tin rao vặt</b></h2></td>
  </tr>
  <tr style="font-size:12px">
    <td align="center" class="title_left">MÃ SỐ</td>
    <td align="center" class="title_row">NGƯỜI TẠO</td>
    <td align="center" class="title_row">TIÊU ĐỀ</td>
    <td align="center" class="title_row">NGÀY ĐĂNG</td>
    <td align="center" class="title_row">NƠI ĐĂNG</td>
    <td align="center" class="title_row">THỂ LOẠI TIN</td>
    <td align="center" class="title_row">MỤC TIN</td>
    <td align="center" class="title_row">LOẠI TIN</td>
	<td align="center" class="title_row">SỐ NGÀY TT</td>
    <td align="center" class="title_row">GIẤY PHÉP</td>
    <td align="center" class="title_row"><font color="#00FF00">Sửa</font></td>
    <td align="center" class="title_row"><font color="#FF0000">Xóa</font></td>
  </tr>
<?php
if(mysql_num_rows($rs) > 0){
	while($rw=mysql_fetch_row($rs)){

echo  '<tr>
    <td class="stt">'.$rw[0].'</td>
    <td class="data_row">'.$rw[1].'</td>
    <td class="data_row">'.$rw[3].'</td>
    <td class="data_row">'.$rw[17].'</td>
    <td class="data_row">'.$rw[6].'</td>
    <td class="data_row">'.$rw[13].'</td>
    <td class="data_row">'.$rw[16].'</td>';
	
	if($rw[9]==1){
    	echo '<td class="data_row">VIP</td>';
	}else {
    	echo '<td class="data_row">Thường</td>';
	}
	
    echo '<td class="data_row">'.$rw[8].'</td>';

	if($rw[11]==1){
    	echo '<td class="data_row">Đã đăng</td>';
	}else {
    	echo '<td class="data_row"><a href="dang_tin_rv/xl_cho_phep_dang_tin_rv.php?mt_rv='.$rw[0].'">Đăng</a></td>';
	}
    echo '<td class="data_row"><a href="index.php?noidung=sua_rv&&mt_rv='.$rw[0].'"><img src="images/edit.gif" border="0" /></a></td>';
    echo '<td class="data_row"><input type="checkbox" name="chkxoa" value="'.$rw[0].'" /></td>';
  echo '</tr>';
}
}
else{
		echo '<tr><td colspan="12" align="center" style="background-color: white; border-left:1px solid gray; border-bottom:1px solid gray; border-right:1px solid gray; padding:5px;">Không tìm thấy</td></tr>';
	}
?>
	<tr>
  		<td height="20"></td>
  	</tr>